﻿/*
	Copyright (C) 2019 Zongming Liu <1849059316@qq.com>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License along
	with this program; if not, write to the Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef RenderQueue_h__
#define RenderQueue_h__

#include "../utility/NonCopyable.h"
#include <memory>
#include <vector>

namespace SkyEngine2d
{
	
	class RenderCommand;
	
	/*!
	 \brief 渲染队列
	 \details
	*/
	class RenderQueue
		:NonCopyable
	{
	public:
		typedef RenderCommand* RenderCommandPtr;
	
		//! 渲染队列的类型
		/*!
			按照渲染命令的全局Z顺序进行分类
		*/
		enum Type
		{
			GLOABL_ZORDER_LOW = 0, /*!< z 顺序小于0. */
			GLOABL_ZORDER_ZERO = 1, /*!< z 顺序等于0. */
			GLOABL_ZORDER_PRECEDENCE = 2, /*!< z 顺序大于0. */
			QUEUE_COUNT	/*!< 类型的总数. */
		};
	
	
	public:
		//! 构造
		RenderQueue();
	
		
		//! 析构
		~RenderQueue();
	
	
		//! 加入一条渲染命令
		/*!
		\param RenderCommandPtr cmd 渲染命令
		\return void 
		*/
		void pushRenderCommand(RenderCommandPtr cmd);
	
		
		//! 获取渲染命令的数量
		/*!
		\return size_t  
		*/
		size_t getSize()const {};
		
		//! 按照全局顺序排序
		void sort();
		
	
		//! 清空queue
		void clear();
		
		
		//! 保存渲染状态
		void saveRenderState();
	
		
		//! 恢复之前的渲染状态
		void restoreRenderState();
		
		//! 获取指令
		/*!
		\param Type queue_type 指令队列的类型
		\return const std::vector<RenderQueue::RenderCommandPtr>& 
		*/
		const std::vector<RenderCommandPtr>& getRenderQueue(Type queue_type);
	
	private:
		std::vector<RenderCommandPtr> m_queues[QUEUE_COUNT];
	};
	
}


#endif // RenderQueue_h__
